Skip to content

feat: FFI null handle guards + go vet cleanup v0.4.0#12

Merged
kolkov merged 2 commits intomainfrom
fix/null-handle-guards
Feb 27, 2026
Merged

feat: FFI null handle guards + go vet cleanup v0.4.0#12
kolkov merged 2 commits intomainfrom
fix/null-handle-guards

Conversation

@kolkov
Copy link
Contributor

@kolkov kolkov commented Feb 27, 2026

Summary

Comprehensive FFI hardening for v0.4.0 — prevents SIGSEGV crashes when passing nil/released objects to wgpu-native.

  • Null handle guards on all public FFI methods (27 files, every Create/Set/Draw/Copy method)
  • ptrFromUintptr helper — eliminates all 15 pre-existing go vet unsafe.Pointer warnings
  • WGPU_NATIVE_PATH env var — override library path for custom wgpu-native locations
  • Improved library loadingloadLibrary returns (Library, error), eager DLL loading on Windows
  • 85 new tests (TestNullGuard_*) — CI-safe, no GPU required

Closes #11

Test plan

  • go build ./... — clean
  • go vet ./... — 0 warnings (was 15)
  • golangci-lint run ./wgpu/ — 0 issues
  • gofmt -l ./wgpu/ — clean
  • 85 null guard tests pass locally
  • CI passes on all platforms (Linux, macOS, Windows)

- Add nil/zero-handle guards on all public FFI methods to prevent SIGSEGV
- Add ptrFromUintptr helper — eliminates all 15 go vet unsafe.Pointer warnings
- Add WGPU_NATIVE_PATH env var for custom library path override
- Change loadLibrary to return (Library, error) with descriptive messages
- Windows: eager DLL loading via dll.Load() for early error detection
- Add 85 null guard tests (CI-safe, no GPU required)
- Update CI test filters to include NullGuard tests
@kolkov kolkov force-pushed the fix/null-handle-guards branch 3 times, most recently from 99ad582 to ad0af04 Compare February 27, 2026 13:39
- Download wgpu-native v27.0.4.0 for all platforms (Linux, macOS, Windows)
- NullGuard tests now run with real library in CI
- Remove go vet -unsafeptr=false (all warnings fixed via ptrFromUintptr)
- Add skipIfNoLibrary fallback for environments without wgpu-native
@kolkov kolkov force-pushed the fix/null-handle-guards branch from ad0af04 to ebfc523 Compare February 27, 2026 13:43
@kolkov kolkov merged commit 5c78684 into main Feb 27, 2026
6 checks passed
@kolkov kolkov deleted the fix/null-handle-guards branch February 27, 2026 13:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Cross-platform hardening: FFI null handle guards + macOS/Linux support

1 participant